package org.bigdata.framework.core.utils;

/**
 * solr动态字段前缀
 * 
 * @author vimes
 * 
 */
public class FieldPrefixUtils {

	/**
	 * 
	 * @param language
	 * @param dataType
	 * @param indexed
	 * @param multiValued
	 * @param stored
	 * @param termVectors
	 * @param required
	 * @return
	 */
	public static String getDynamicField(String dataType, String language,
			String multiLanguage, String indexed, String multiValued,
			String stored, String termVectors, String required) {
		String fieldStr = "";
		if ("1".equals(multiLanguage)) {
			fieldStr += "auto_";
		} else if (language != null && !"".equals(language)) {
			fieldStr += language + "_";
		}
		fieldStr += dataType;
		if ("1".equals(indexed)) {
			if ("1".equals(multiLanguage)
					|| (language != null && !"".equals(language))) {
				fieldStr += "IT";
			} else {
				fieldStr += "I";
			}
		}
		if ("1".equals(multiValued)) {
			fieldStr += "M";
		}
		if ("1".equals(stored)) {
			fieldStr += "S";
		}
		if ("1".equals(termVectors)) {
			fieldStr += "V";
		}
		fieldStr += "_";
		return fieldStr;
	}

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		String fieldStr = FieldPrefixUtils.getDynamicField("string", null, "0",
				"1", "1", "1", "1", "0");
		System.out.println(fieldStr);
	}
}
